package mytest.wd;

import com.google.gson.Gson;
import org.apache.commons.lang3.StringUtils;
import pojo.BSMSB2Origin;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @author huangyulu
 * @date 2024/6/6 15:50
 * @Description
 */
public class BSMSB2Origin0701 {
    public static void main(String[] args) {
        List<String[][]> dataExcel = ExcelUtil.
                readExcelFile("C:\\Users\\86187\\Desktop\\first.xlsx");

        List<BSMSB2Origin> bsmsOriginEntities = new ArrayList<>();
        // 遍历 List<String[][]>
        for (String[][] sheet : dataExcel) {
            // 遍历 String[][]
            for (String[] row : sheet) {
                // 遍历 String[]
                if ((StringUtils.isBlank(row[0]))) {
                    continue;
                }
                if (row[0].contains("mob")) {
                    continue;
                }
                BSMSB2Origin entity = new BSMSB2Origin(row[0], row[1]);
                bsmsOriginEntities.add(entity);
            }
        }

        for (BSMSB2Origin entity : bsmsOriginEntities) {

            // 创建一个打开的文件输出流，用写入文件
            FileOutputStream fos = null;
            try {
                fos = new FileOutputStream("output_20240708_1.json", true);
                // 创建一个打印输出流，用于封装文件输出流
                PrintStream ps = new PrintStream(fos);
                // 将系统的输出重定向到打印输出流
                System.setOut(ps);
                System.out.println(new Gson().toJson(entity));
//                System.out.println(eventTime + "," + channel + "," + facebookAF.getAppsFlyerId());
                // 写入文件的内容
                // 关闭打印输出流
                ps.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }

}
